import 'dart:convert';

import 'package:encrypt/encrypt.dart';
import 'package:study_online/utils/rsaKeys.dart';
import 'RSAUtils.dart';

String encodeString(String content) {
  //var list = RSAUtils.generateKeys(1024);
  var rsa = RSAUtils.getInstance(RsaKey.puKey, RsaKey.prKey);
  var enstr = rsa.encryptByPublicKey(utf8.encode(content));
  return base64.encode(enstr);
}

bool judge(String pwd1, String pwd2) {
  var rsa = RSAUtils.getInstance(RsaKey.puKey, RsaKey.prKey);
  var p1 = rsa.decryptByPrivateKey(base64.decode(pwd1));
  var p2 = rsa.decryptByPrivateKey(base64.decode(pwd2));
  return utf8.decode(p1) == utf8.decode(p2);
}
